﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BookShopSample
{

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            

        }

        private void btOk_Click(object sender, EventArgs e)
        {

            cbCategory.Items.Clear();
            using (SqlConnection con = new SqlConnection())
            {
                
                con.ConnectionString = tbConnection.Text;
                con.Open();
                string strSQL = "SELECT * FROM category";
                SqlCommand myCommand = new SqlCommand(strSQL, con);

                using (SqlDataReader strReader = myCommand.ExecuteReader())
                {
                    while (strReader.Read())
                    {
                        string s = strReader["name"].ToString();
                        cbCategory.Items.Add(s);

                    }
                }
            }
        }

        private void btAdd_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();
            f2.Show();
        }

        private void btRemove_Click(object sender, EventArgs e)
        {
            Form3 f3 = new Form3();
            f3.Show();
        }


    }
    public class ComboboxItem
    {
        public string Text { get; set; }
        public object Value { get; set; }

        public override string ToString()
        {
            return Text;
        }
    }
}
